#ifndef STRATEGY_H
#define STRATEGY_H

#include <memory>
#include <unordered_map>
#include <set>
#include "Struct.h"
#include "Timer.hpp"
#include "json.hpp"
struct Ticker
{
	char name[16];
	int idx;
	int position;
	long position_nano;
	long ptr;
	double margin;
	double pnl;
	Snapshot last;
};

class Strategy
{
public:
	virtual void on_process(const Ticker* data)=0;
	virtual void on_init(const nlohmann::json config){};
	bool init(const nlohmann::json config);
	void send_order(int volume, char offset, int idx);
	long get_nano(){return md_nano_;};
	int get_nsymbol(){return nsymbol_;};
	const char* get_log_name(){return log_name_.c_str();};
	bool is_real_time(){return print_log_;};
	void run();

private:
	void process(int idx, const Snapshot* data);
	bool is_trading(int t);
	bool real_time_=false;
	bool print_log_=false;
	long md_nano_=0;
	long cur_nano_=0;
	int nsymbol_=0;
	int order_id_=0;
	int REAL;
	Ticker* cache_;
	std::vector<std::pair<int,int> > trading_period;
	Order* orders_;
	std::string log_name_;
	char MARKET_DATA[32];
	long START_TIME_;
};

#endif
